public class Practice03 {
    public static void main(String[] args) {
        int[] arr = new int[]{28, 5, 11, 9, 2, 35, 18};
        // 定义交换数字时临时存放用变量
        int box;
        // 循环检查所有数字是否已排列完毕
        for (int i = 0; i < arr.length; i++) {
            // 核心语句：判断相邻数字大小并按照大小重新排序
            for (int j = 0; j < arr.length - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    box = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = box;
                }
            }
        }
        for (int a = 0; a < arr.length; a++) {
            System.out.println(arr[a]);
        }
    }
}
